def deci(y):
L=[]
for i in range(len(y)):
L.append(int(y[i]))
return L
for _ in range(int(input())):
n,k=map(int,input().split())
for i in range(k-1):
if 0 in deci(str(n)):
break
n=n+(min(deci(str(n)))*max(deci(str(n))))
print(n)
/*
Author: Atul chandra
*/
#include<bits/stdc++.h>
using namespace std;
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rloop(i,a,b) for(long long i=a;i>=b;i--)
#define ll long long
#define mp make_pair
#define pb push_back
#define vll vector<long long>
#define vvl vector<vll>
#define pll pair<ll,ll>
#define vc vector
#define ff first
#define ss second
#define lb lower_bound
#define POW(a,b) (ll)(pow(a,b)+0.5)
#define gcd __gcd
#define remove_unique(x) x.erase(unique(x.begin(),x.end()),x.end())
#define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define p_q priority_queue
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vector<ll>,greater<ll>>
#define all(x) x.begin(),x.end()
#define inc(x,start) iota(x.begin(),x.end(),start)
#define pi 3.141592653589793238
#define inf LONG_LONG_MAX
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define ios ios_base::sync_with_stdio(0)
#define tie cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
// long long Ceil(long long a,long long b){return (a+b-1)/b;}
// long long Sqrt(long long x){ long long y=sqrt(x)+5;while(y*y>x)y--;return y;}
template <class T> void _print(T t){ cerr << t;}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
//--------------------------------------------------------------------------------------------------------------------------------------//
/* Atul chandra */
//--------------------------------------------------------------------------------------------------------------------------------------//
const int mod = 1e9 + 7;
void helper(){
ll a,k;
cin>>a>>k;
k--;
while(k>0){
ll m = a;
int mini = 10;
int maxi = 0;
while(m>0){
int d = m%10;
mini = min(mini, d);
maxi = max(maxi, d);
m/=10;
}
if(mini == 0) break;
a += (mini*maxi);
k--;
}
cout<<a<<endl;
}
int main(){
ios;tie;
int T;
cin>>T;
while(T--){
helper();
}
return 0;
}
509A - Maximum in Table | 1647C - Madoka and Childish Pranks |
689B - Mike and Shortcuts | 379B - New Year Present |
1498A - GCD Sum | 1277C - As Simple as One and Two |
1301A - Three Strings | 460A - Vasya and Socks |
1624C - Division by Two and Permutation | 1288A - Deadline |
1617A - Forbidden Subsequence | 914A - Perfect Squares |
873D - Merge Sort | 1251A - Broken Keyboard |
463B - Caisa and Pylons | 584A - Olesya and Rodion |
799A - Carrot Cakes | 1569B - Chess Tournament |
1047B - Cover Points | 1381B - Unmerge |
1256A - Payment Without Change | 908B - New Year and Buggy Bot |
979A - Pizza Pizza Pizza | 731A - Night at the Museum |
742A - Arpa’s hard exam and Mehrdad’s naive cheat | 1492A - Three swimmers |
1360E - Polygon | 1517D - Explorer Space |
1230B - Ania and Minimizing | 1201A - Important Exam |